//
//  CCFoundationTests.m
//  CCFoundationTests
//
//  Created by zjh on 2021/8/25.
//

#import <XCTest/XCTest.h>
//#import "CCFoundationMacros.h"
#import "Person.h"
@interface CCFoundationTests : XCTestCase <NSURLSessionTaskDelegate>

@end

@implementation CCFoundationTests

- (void)setUp {
    // Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
}

- (void)testExample {
//    __block NSInteger a = 1;
    __block Person *obj = [[Person alloc] init];
    obj.name = @"你好";
    NSLog(@"内存地址：%@",obj);
    __block NSInteger a = 1;
    dispatch_semaphore_t t = dispatch_semaphore_create(0);
    void(^block)(void) = ^(void) {
        Person *obj1 = [[Person alloc] init];
        obj1.name = @"你好吗";
        obj = obj1;
        NSLog(@"内存地址：%@",obj);
        a = 2;
        NSLog(@"内存地址：%ld",a);
    };
    block();
    NSLog(@"内存地址：%ld",obj);
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//        obj = 3;
        NSLog(@"内存地址：%ld",a);
        dispatch_semaphore_signal(t);
    });
    dispatch_semaphore_wait(t, DISPATCH_TIME_FOREVER);
    NSLog(@"内存地址1：%@",obj);
    // This is an example of a functional test case.
    // Use XCTAssert and related functions to verify your tests produce the correct results.
}

- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didFinishCollectingMetrics:(NSURLSessionTaskMetrics *)metrics {
    for (NSURLSessionTaskTransactionMetrics *obj in metrics.transactionMetrics) {
        NSLog(@"%@",obj.request.URL);
        NSLog(@"%@",obj.networkProtocolName);
    }
}

- (void)sleepAction {
    NSLog(@"当前线程4%@",[NSThread currentThread]);
    [NSThread sleepForTimeInterval:1];
}

- (void)testPerformanceExample {
    // This is an example of a performance test case.
    [self measureBlock:^{
        // Put the code you want to measure the time of here.
    }];
}

@end
